import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by aswathik on 6/4/14.
 */
public class PrimeFactorExcercise {
    ArrayList<Integer> generatePrimeFactors(int number) {

        ArrayList<Integer> listOfPrimeFactors = new ArrayList<Integer>();

        int factor = 2;
        while ( number > 1 ) {
            if ( (number % factor) == 0 ) {
                listOfPrimeFactors.add(factor);
                number = number / factor;
                if ( number == factor)
                    number = number/factor;
            }
            factor++;
        }
        return listOfPrimeFactors;
    }

    public static void main(String[] args) {
        PrimeFactorExcercise primeFactorExcercise = new PrimeFactorExcercise();
        ArrayList<Integer> returnedListOfFactors = new ArrayList<Integer>();

        System.out.println(" Enter the number for getting prime factors ");
        Scanner newScanner = new Scanner(System.in);
        int number = newScanner.nextInt();

        returnedListOfFactors = primeFactorExcercise.generatePrimeFactors(number);
        System.out.println(" The list is ");
        for ( int i = 0; i < returnedListOfFactors.size(); i++) {
            System.out.print(returnedListOfFactors.get(i)+" ,");
        }
    }

}
